﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.UserData;


using System.IO.IsolatedStorage;
using System.IO;

namespace Stundenplan_TSST
{
    public partial class Settings : PhoneApplicationPage
    {
        //-------------------------------------------------------------
        App app = (App)Application.Current; // dem Symbol app alles aus der Datei App.xaml zuweisen
        List<string> strList_Klassen = new List<string>(); // String-Liste strList_Klassen mit den Klassen deklarieren        
        //-------------------------------------------------------------
        public Settings()
        {
            InitializeComponent();
            if (app.strKlasse != null)
            {
                textBlock1.Text = ("Derzeit ausgewählt: " + app.strKlasse);
            }
        }
        //-------------------------------------------------------------
        public void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            listPicker_Klassen_fill();
        }
        //-------------------------------------------------------------
        public void listPicker_Klassen_fill()
        {
            strList_Klassen.Clear();
            #region Namen der Klassen
            strList_Klassen.Add("TGM11");
            strList_Klassen.Add("TGM12");
            //-------------------------------------------------------------
            strList_Klassen.Add("ITAU1");
            strList_Klassen.Add("ITAM1");
            strList_Klassen.Add("ITAO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("12B1");
            strList_Klassen.Add("12B2");
            strList_Klassen.Add("12B3");
            //-------------------------------------------------------------
            strList_Klassen.Add("FSM1");
            //-------------------------------------------------------------
            strList_Klassen.Add("BFMU1");
            strList_Klassen.Add("BFMHO");
            //-------------------------------------------------------------
            strList_Klassen.Add("BFHU1");
            //-------------------------------------------------------------
            strList_Klassen.Add("BFEU1");
            strList_Klassen.Add("BFEO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("BGJE");
            strList_Klassen.Add("BGJF");
            strList_Klassen.Add("BGJH");
            strList_Klassen.Add("BGJM");
            strList_Klassen.Add("BGJK");
            //-------------------------------------------------------------
            strList_Klassen.Add("MEU1");
            strList_Klassen.Add("MEU3");
            strList_Klassen.Add("MEU4");

            strList_Klassen.Add("MEM1");
            strList_Klassen.Add("MEM3");
            strList_Klassen.Add("MEM4");

            strList_Klassen.Add("MEO1");
            strList_Klassen.Add("MEO3");
            strList_Klassen.Add("MEO4");
            //-------------------------------------------------------------
            strList_Klassen.Add("MHSU");
            strList_Klassen.Add("MHSM");
            strList_Klassen.Add("MHSO");
            //-------------------------------------------------------------
            strList_Klassen.Add("KFZU1");
            strList_Klassen.Add("KFZU2");
            strList_Klassen.Add("KFZU3");

            strList_Klassen.Add("KFZM1");
            strList_Klassen.Add("KFZM2");

            strList_Klassen.Add("KFZO1");
            strList_Klassen.Add("KFZO2");
            //-------------------------------------------------------------
            strList_Klassen.Add("KLMU1");
            strList_Klassen.Add("KLMM1");
            strList_Klassen.Add("KLMO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("ELU1");
            strList_Klassen.Add("ELU2");

            strList_Klassen.Add("ELM1");
            strList_Klassen.Add("ELM2");
            strList_Klassen.Add("ELM3");

            strList_Klassen.Add("ELO1");
            strList_Klassen.Add("ELO2");
            //-------------------------------------------------------------
            strList_Klassen.Add("BMU1");
            strList_Klassen.Add("BMM1");
            strList_Klassen.Add("BMO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("HTIU1");
            strList_Klassen.Add("HTIU2");

            strList_Klassen.Add("HTIM1");
            strList_Klassen.Add("HTIM2");

            strList_Klassen.Add("HTIO1");
            strList_Klassen.Add("HTIO2");
            //-------------------------------------------------------------
            strList_Klassen.Add("HTFWM");
            strList_Klassen.Add("HTFWO");
            //-------------------------------------------------------------
            strList_Klassen.Add("MALU1");
            strList_Klassen.Add("MALU2");

            strList_Klassen.Add("MALM1");
            strList_Klassen.Add("MALM2");

            strList_Klassen.Add("MALO1");
            strList_Klassen.Add("MALO2");
            //-------------------------------------------------------------
            strList_Klassen.Add("TEXU1");
            strList_Klassen.Add("TEXU2");

            strList_Klassen.Add("TEXM1");

            strList_Klassen.Add("TEXO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("GAU1");
            strList_Klassen.Add("GAU2");

            strList_Klassen.Add("GAM1");
            strList_Klassen.Add("GAM2");

            strList_Klassen.Add("GAO1");
            strList_Klassen.Add("GAO2");
            //-------------------------------------------------------------
            strList_Klassen.Add("GAWU1");
            strList_Klassen.Add("GAWU2");

            strList_Klassen.Add("GAWM");

            strList_Klassen.Add("GAWO1");
            //-------------------------------------------------------------
            strList_Klassen.Add("JDU1");
            strList_Klassen.Add("JDU2");
            strList_Klassen.Add("JDU3");
            //-------------------------------------------------------------
            strList_Klassen.Add("FORE");
            //-------------------------------------------------------------
            strList_Klassen.Add("EUM");
            //-------------------------------------------------------------
            strList_Klassen.Add("AERU");
            //-------------------------------------------------------------
            strList_Klassen.Add("LABOR F");
            #endregion            
            app.intAnzahlKlassen = strList_Klassen.Count();
            autoCompleteBox_Klassen.ItemsSource = strList_Klassen;
        }

        private void autoCompleteBox_Klassen_DropDownClosing(object sender, RoutedPropertyChangingEventArgs<bool> e)
        {
            string strTempKlasse;            
            if (autoCompleteBox_Klassen.SelectedItem == null)
            {
                strTempKlasse = Convert.ToString(autoCompleteBox_Klassen.Text);
            }
            else
            {
                strTempKlasse = Convert.ToString(autoCompleteBox_Klassen.SelectedItem);
            }
            app.strKlasse = strTempKlasse.ToUpper(); // Die Eingabe/Auswahl nur in Großbuchstaben in den String schreiben
            //-------------------------------------------------------------
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;            
            if (!settings.Contains("Klasse")) // Wenn die Einsetllungen 
            {
                settings.Add("Klasse", Convert.ToString(autoCompleteBox_Klassen.SelectedItem));
            }
            else
            {
                settings["Klasse"] = Convert.ToString(autoCompleteBox_Klassen.SelectedItem);
            }
            //-------------------------------------------------------------
        }

        private void AppBar_Icon_Stundenplan_Click(object sender, EventArgs e)
        {            
            NavigationService.GoBack();
        }
    }
}